package com.frxuexi.park2212.patrol

import androidx.lifecycle.MutableLiveData
import com.frxuexi.lib_base.base.BaseViewModel
import com.frxuexi.lib_base.entity.PatrolTaskBean
import com.frxuexi.lib_base.entity.PatrolTaskBeanItem
import com.frxuexi.lib_base.entity.PointBean
import com.frxuexi.lib_base.entity.PointBeanItem
import com.frxuexi.lib_base.entity.RepairBean
import com.frxuexi.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import retrofit2.http.Query
import javax.inject.Inject

@HiltViewModel
class PatrolViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {
    var getPoints = MutableLiveData<PointBean>()

    var getPointById = MutableLiveData<PointBeanItem>()

    var getTasks = MutableLiveData<PatrolTaskBean>()

    var getOrders = MutableLiveData<RepairBean>()

    var getTasksByStatus = MutableLiveData<PatrolTaskBean>()

    var getTasksBId = MutableLiveData<PatrolTaskBeanItem>()

    fun getPoints(){
        httpRequest({apiService.getPoints()},getPoints::postValue)
    }

    fun getPointsByType(location:String,type:String){
        httpRequest({apiService.getPointsByType(location,type)},getPoints::postValue)
    }

    fun getPointsById(id:Int){
        httpRequest({apiService.getPointById(id)},getPointById::postValue)
    }

    fun getTasks(){
        httpRequest({apiService.getPatrolTasks()},getTasks::postValue)
    }

    fun getOrders(){
        httpRequest({apiService.getRepairs()},getOrders::postValue)
    }

    fun getTasksByStatus(status:String){
        httpRequest({apiService.getPatrolTaskByStatus(status)},getTasksByStatus::postValue)
    }

    fun getTaskById(id:Int){
        httpRequest({apiService.getTaskById(id)},getTasksBId::postValue)
    }


}